Conversation
Each TCP port-forward rule used to burn one thread that polled TcpListener::accept() with 50 ms sleeps between WouldBlock returns. That thread was both the accept-latency floor and the only piece of networking still polling on a fixed cadence after Phase 6.4. Listener FDs are exactly what EpollDispatch handles. Bind + register the listener under PROTO_TAG_LISTEN at construction time; the net-poll thread sees readiness, accepts the connection (drains WouldBlock), and feeds the existing InboundAccept channel. No dedicated thread per rule. Drops port_forward_accept_latency from ~50 ms to sub-millisecond (divan microbench is host TcpStream::connect → first frame in inject_to_guest, now bounded by epoll_wait latency in the active 5 ms cadence rather than a fixed 50 ms poll). Removes: - run_port_forward_listener (thread main loop) - spawn_port_forward_listeners (now bind_port_forward_listeners) - PORT_FORWARD_POLL_INTERVAL - port_forward_shutdown Arc<AtomicBool> - the Drop impl block that joined listener threads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Each TCP port-forward rule used to burn one thread polling
TcpListener::accept()with 50 ms sleeps betweenWouldBlockreturns. That thread was both the accept-latency floor and the only piece of networking still polling on a fixed cadence after Phase 6.4.Listener FDs are exactly what
EpollDispatchhandles. Bind + register the listener underPROTO_TAG_LISTENat construction time; the net-poll thread sees readiness, accepts the connection (drainsWouldBlock), and feeds the existingInboundAcceptchannel. No dedicated thread per rule.Drops
port_forward_accept_latencyfrom ~50 ms to sub-millisecond — bounded byepoll_wait's active 5 ms cadence rather than a fixed 50 ms poll.Removes
run_port_forward_listener(thread main loop)spawn_port_forward_listeners(nowbind_port_forward_listeners)PORT_FORWARD_POLL_INTERVALport_forward_shutdownArc<AtomicBool>Dropimpl block that joined listener threadsReplaces #72
This is the single substantive commit (
e51e409) that #72 was meant to land, cherry-picked clean onto currentmain. PR #72 carried 121 stale commits that were squash-merged via PR #69 — closing it in favor of this clean PR.Test plan
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets --all-features -- -D warnings— cleanRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features— cleancargo test --test network_baseline -- --test-threads=1— 18/18File changes
benches/network.rs— bench harness updated to seed listeners throughbind_port_forward_listenerssrc/network/slirp.rs— listener path moved ontoEpollDispatch(+158/-171)